#填入家长督学平台的账号和密码，自动计算绩点


from selenium import webdriver
from selenium.webdriver.common.by import By

keys = input("请输入家长督学平台的账号：(默认身份证号)  ")
secret = input("请输入家长督学平台的密码：(默认身份证号后六位)  ")

wd = webdriver.Chrome()
wd.implicitly_wait(30)


wd.get('http://jwxt.wit.edu.cn/jzdx/kscj/cjcx_list')

element = wd.find_element(By.CSS_SELECTOR,'#xh')
element.send_keys(keys)

element = wd.find_element(By.CSS_SELECTOR,'#pwd')
element.send_keys(secret)

element = wd.find_element(By.CSS_SELECTOR,'#btnSubmit')
element.click()

element = wd.find_element(By.CSS_SELECTOR,'#calender_user_schedule')
element.click()

element = wd.find_element(By.CSS_SELECTOR,'#btn_query')
element.click()

scores = wd.find_elements(By.CSS_SELECTOR,'.Nsb_pw > table:nth-of-type(1) tr > td:nth-child(5)')

xuefens = wd.find_elements(By.CSS_SELECTOR,'.Nsb_pw > table:nth-of-type(1) tr > td:nth-child(6)')

zongxuefun = 0
zongfenshu = 0

for xuefen in xuefens:
    zongxuefun += float(xuefen.text)


for s,x in zip(scores,xuefens):
    zongfenshu += float(s.text)*float(x.text)


print("{:.2f}".format((zongfenshu/zongxuefun - 50)/10))

wd.quit()